package com.lvyq.qrobot.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lvyq.qrobot.entity.UserEntity;
import com.lvyq.qrobot.entity.UserMsg;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * @author lvyq
 * @version 1.0
 * Create by 2024-05-31 9:47
 */
@Mapper
public interface UserMsgMapper extends BaseMapper<UserMsg> {

    @Select("SELECT ls.* FROM (SELECT user_name AS name,COUNT(*) AS count FROM user_msg WHERE create_time = #{createTime} AND group_id= #{groupId} GROUP BY user_id) as ls WHERE 1=1  ORDER BY count DESC LIMIT 3")
    List<Map<String,Object>> totalMsgCount(@Param("groupId") Integer groupId,String createTime);
}
